Skip to content

Conversation

@kul3r4
Copy link
Contributor

@kul3r4 kul3r4 commented Oct 9, 2025

@kul3r4 kul3r4 added the wear_maintenance Improvement to Wear pages label Oct 9, 2025
@kul3r4 kul3r4 requested a review from Copilot October 9, 2025 16:00
@snippet-bot
Copy link

snippet-bot bot commented Oct 9, 2025

Here is the summary of changes.

You are about to add 1 region tag.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@kul3r4 kul3r4 requested a review from garanj October 9, 2025 16:00
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a location detection snippet for Android Wear OS that demonstrates how to check if GPS is available on the device. The implementation follows the Android developer documentation for location detection in wearable apps.

  • Adds a new LocationActivity with GPS availability checking functionality
  • Creates a Compose UI that displays different messages based on GPS availability
  • Registers the new activity in the Android manifest

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
wear/src/main/java/com/example/wear/snippets/location/LocationActivity.kt New activity implementing GPS detection with Compose UI for displaying GPS availability status
wear/src/main/AndroidManifest.xml Registers LocationActivity in the manifest with required configuration

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +77 to +78
}
else {
Copy link

Copilot AI Oct 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Use consistent formatting for the else clause. Either place 'else' on the same line as the closing brace or use braces for consistency with the if block.

Suggested change
}
else {
} else {

Copilot uses AI. Check for mistakes.
}
// [END_EXCLUDE]
}
fun hasGps(): Boolean =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do hasSystemFeature(PackageManager.FEATURE_LOCATION_GPS) and LocationManagerCompat.isLocationEnabled(locationManager) interoperate and is the latter relevant here?

For example, if the watch has GPS, but Location is disabled in the settings, do these return true and false respectively, and does that matter in this use case?

Or does FEATURE_LOCATION_GPS already take into account whether location is enabled by the location setting?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for raising, it does NOT take into account whether location is enabled by the user setting. The current documentation doesn't mention it but I can add a new section and also mention this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rereading https://developer.android.com/training/wearables/apps/location-detection#DetectGPS, this is for GPS only and there is another section for requesting permissions and in https://developer.android.com/develop/sensors-and-location/location/retrieve-current?#last-known (which is linked from the same page) it explains what happens when location is tuned off in settings.

In summary: I think this snippet works as it is as this section is only focusing on gps, other sections of the same page cover the other cases.

@garanj garanj self-requested a review October 10, 2025 10:05
@kul3r4 kul3r4 merged commit fcf8a03 into main Oct 10, 2025
5 checks passed
@kul3r4 kul3r4 deleted the pager branch October 12, 2025 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wear_maintenance Improvement to Wear pages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants